package com.chinatelecom.epush.db;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;


/**
 * 
 * 文件存储设置参数
 * 
 */
public class SharedPreferencesData {

	private SharedPreferences shareData;
	private final String PREFS_NAME = "cn.com.telecom.telecomdetails";

	private final String NAME = "name";
	private final String USER_ID = "userId";

	private final String VALIDATE = "validate";// 是否通过验证֤
	private final String USED = "used";// 是否正在使用
	private final String LOGIN_SIGN = "loginsign";// 唯一标识码
	private final String NEED_RE_VALIDATE = "needrevalidate"; // 标识是否需要重新验证֤
	private final String LOGIN_MOBILE = "loginmobile";// 验证时使用的电话号码
	private final String DEPARTMENT = "department";
	private final String DEPARTMENT_ID = "departmentID";
	private final String LOGIN_NAME = "loginName";
	private final String SECOND_NAME = "secendName";
	private final String MSG_RECEIVED_NUM = "msgReceivedNum";
	private final String PHONENUM_XIAO = "phoneNumXiao";
	private final String PHONENUM_JIA = "phoneNumJia";
	private final String PHONENUM_OFFICE = "phoneNumOffice";
	private final String PHONENUM_TIAN = "phoneNumTian";
	private final String PHONENUM_YI = "phoneNumYi";
	private final String E_MAIL = "email";
	private final String ID_CARD = "idCard";
	private final String SHEME = "sheme";
	private final String ADDRESS_UPDATE_DATE = "addressUpdateDate";



	public SharedPreferencesData(Context context) {
		shareData = context.getSharedPreferences(PREFS_NAME,
				Context.MODE_WORLD_WRITEABLE);
	}

	// true表示通过验证,false表示未通过验证֤
	public String getValidate() {
		return shareData.getString(this.VALIDATE, "false");
	}

	public void setValidate(String validate) {
		Editor editor = shareData.edit();
		editor.putString(this.VALIDATE, validate);
		editor.commit();
	}

	
	public String getUsed() {
		return shareData.getString(this.USED, "false");
	}

	public void setUsed(String used) {
		Editor editor = shareData.edit();
		editor.putString(this.USED, used);
		editor.commit();
	}

	public String getName() {
		return shareData.getString(this.NAME, "");
	}

	public void setName(String name) {
		Editor editor = shareData.edit();
		editor.putString(this.NAME, name);
		editor.commit();
	}

	public int getUserId() {
		return shareData.getInt(this.USER_ID, 0);
	}

	public void setUserId(int userId) {
		Editor editor = shareData.edit();
		editor.putInt(this.USER_ID, userId);
		editor.commit();
	}

	public String getLoginSign() {
		return shareData.getString(this.LOGIN_SIGN, "");
	}

	public void setLoginSign(String loginsign) {
		Editor editor = shareData.edit();
		editor.putString(this.LOGIN_SIGN, loginsign);
		editor.commit();
	}

	public String getDepartment() {
		return shareData.getString(this.DEPARTMENT, "");
	}

	public void setDepartment(String department) {
		Editor editor = shareData.edit();
		editor.putString(this.DEPARTMENT, department);
		editor.commit();
	}

	public int getDepartmentID() {
		return shareData.getInt(this.DEPARTMENT_ID, 0);
	}

	public void setDepartmentID(int departmentID) {
		Editor editor = shareData.edit();
		editor.putInt(this.DEPARTMENT_ID, departmentID);
		editor.commit();
	}

	// LoginName
	public String getLoginName() {
		return shareData.getString(this.LOGIN_NAME, "");
	}

	public void setLoginName(String loginName) {
		Editor editor = shareData.edit();
		editor.putString(this.LOGIN_NAME, loginName);
		editor.commit();
	}

	// secendName
	public String getSecondName() {
		return shareData.getString(this.SECOND_NAME, "");
	}

	public void setSecondName(String secondName) {
		Editor editor = shareData.edit();
		editor.putString(this.SECOND_NAME, secondName);
		editor.commit();
	}

	// msgReceivedNum
	public String getMsgReceivedNum() {
		return shareData.getString(this.MSG_RECEIVED_NUM, "");
	}

	public void setMsgReceivedNum(String msgReceivedNum) {
		Editor editor = shareData.edit();
		editor.putString(this.MSG_RECEIVED_NUM, msgReceivedNum);
		editor.commit();
	}

	// phoneNumXiao
	public String getPhoneNumXiao() {
		return shareData.getString(this.PHONENUM_XIAO, "");
	}

	public void setPhoneNumXiao(String phoneNumXiao) {
		Editor editor = shareData.edit();
		editor.putString(this.PHONENUM_XIAO, phoneNumXiao);
		editor.commit();
	}

	// phoneNumJia
	public String getPhoneNumJia() {
		return shareData.getString(this.PHONENUM_JIA, "");
	}

	public void setPhoneNumJia(String phoneNumJia) {
		Editor editor = shareData.edit();
		editor.putString(this.PHONENUM_JIA, phoneNumJia);
		editor.commit();
	}

	// phoneNumOffice
	public String getPhoneNumOffice() {
		return shareData.getString(this.PHONENUM_OFFICE, "");
	}

	public void setPhoneNumOffice(String phoneNumOffice) {
		Editor editor = shareData.edit();
		editor.putString(this.PHONENUM_OFFICE, phoneNumOffice);
		editor.commit();
	}

	// PhoneNumTian
	public String getPhoneNumTian() {
		return shareData.getString(this.PHONENUM_TIAN, "");
	}

	public void setPhoneNumTian(String phoneNumTian) {
		Editor editor = shareData.edit();
		editor.putString(this.PHONENUM_TIAN, phoneNumTian);
		editor.commit();
	}

	// PhoneNumYi
	public String getPhoneNumYi() {
		return shareData.getString(this.PHONENUM_YI, "");
	}

	public void setPhoneNumYi(String phoneNumYi) {
		Editor editor = shareData.edit();
		editor.putString(this.PHONENUM_YI, phoneNumYi);
		editor.commit();
	}

	// Email
	public String getEmail() {
		return shareData.getString(this.E_MAIL, "");
	}

	public void setEmail(String email) {
		Editor editor = shareData.edit();
		editor.putString(this.E_MAIL, email);
		editor.commit();
	}

	// IdCard
	public String getIdCard() {
		return shareData.getString(this.ID_CARD, "");
	}

	public void setIdCard(String idCard) {
		Editor editor = shareData.edit();
		editor.putString(this.ID_CARD, idCard);
		editor.commit();
	}

	public String getSheme() {
		return shareData.getString(this.SHEME, "blue");
	}

	public void setSheme(String sheme) {
		Editor editor = shareData.edit();
		editor.putString(this.SHEME, sheme);
		editor.commit();
	}

	public String getAddressUpdateDate() {
		return shareData.getString(this.ADDRESS_UPDATE_DATE, "");
	}

	public void setAddressUpdateDate(String date) {
		Editor editor = shareData.edit();
		editor.putString(this.ADDRESS_UPDATE_DATE, date);
		editor.commit();
	}
	public String getNeedReValidate() {
		return shareData.getString(this.NEED_RE_VALIDATE, "y");
	}

	public void setNeedReValidate(String needrevalidate) {
		Editor editor = shareData.edit();
		editor.putString(this.NEED_RE_VALIDATE, needrevalidate);
		editor.commit();
	}

	public String getLoginMobile() {
		return shareData.getString(this.LOGIN_MOBILE, "");
	}

	public void setLoginMobile(String loginmobile) {
		Editor editor = shareData.edit();
		editor.putString(this.LOGIN_MOBILE, loginmobile);
		editor.commit();
	}
	
	public void resetUserInfo() {
		
			setLoginName("");
			setName("");
			setPhoneNumTian("");
			setLoginMobile("");
			setLoginSign("");
			
	}
}
